package com.yl.auth.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yl.auth.entity.Fangjianleixing;
import com.yl.auth.mapper.FangjianleixingMapper;
import com.yl.auth.service.FangjianleixingService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ln
 * @since 2023-06-17
 */
@Service
public class FangjianleixingServiceImpl extends ServiceImpl<FangjianleixingMapper, Fangjianleixing> implements FangjianleixingService {
    @Resource
    private FangjianleixingMapper fangjianleixingMapper;
    @Override
    public IPage<Fangjianleixing> findzidian(Page<Fangjianleixing> pagefarm) {
        return fangjianleixingMapper.findzidian(pagefarm);
    }

    @Override
    public void add(Fangjianleixing fangjianleixing) {
        fangjianleixingMapper.add(fangjianleixing);
    }

    @Override
    public Fangjianleixing getByIdleixing(Long id) {
        Fangjianleixing byIdleixing = fangjianleixingMapper.getByIdleixing(id);
        Integer countlei = 0;
        if (byIdleixing.getCount() != 0) {
            // 检查当前床位是否有老人
            countlei = 1;
        }
        byIdleixing.setLeixingcount(countlei);
        return byIdleixing;
    }
}
